package ver1.pixel.handler;

import java.awt.image.BufferedImage;

public class BlurHandler {
	
	public int blur(BufferedImage img,int ulx,int uly,int drx,int dry,double[][] matrix){
		double sumR=0,sumG=0,sumB=0;
		int pixel=0,red=0,green,blue=0;
		for(int x=ulx,mx=0;x<=drx;x++,mx++){
			for(int y=uly,my=0;y<=dry;y++,my++){
				pixel=img.getRGB(x, y);
				red=(pixel&0x00ff0000)>>16;
				green=(pixel&0x0000ff00)>>8;
				blue=(pixel&0x000000ff);
				sumR+=red*matrix[mx][my];
				sumG+=green*matrix[mx][my];
				sumB+=blue*matrix[mx][my];
			}
		}
		return (-1<<24)|((int)sumR<<16)|((int)sumG<<8)|((int)sumB);
	}
	
}
